package com.zaofan.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.ShopCategory;
import com.zaofan.dao.ShopCategoryDao;

public class ShopCategoryService {

	private ShopCategoryDao shopCategoryDao = new ShopCategoryDao();

	public void delete(ShopCategory shopCategory) {
		shopCategoryDao.del(shopCategory);
	}

	public void add(ShopCategory shopCategory) {
		shopCategoryDao.add(shopCategory);
	}

	public void update(ShopCategory shopCategory) {
		shopCategoryDao.update(shopCategory);
	}

	public List<ShopCategory> findAll(Map<String, Object> params) {
		List<ShopCategory> data = shopCategoryDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return shopCategoryDao.count(params);
	}

	public ShopCategory findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return shopCategoryDao.findOne(params);
	}

	public List<ShopCategory> findByShopId(Integer shopId) {
		Map<String, Object> params = new HashMap<>();
		params.put("shopId", shopId);
		params.put("order", " by sort asc");
		return findAll(params);
	}

	public List<ShopCategory> findByShopIdAndSort(int shopId, int sort_b, int sort_e) {
		return shopCategoryDao.findByShopIdAndSort(shopId,sort_b,sort_e);
	}

}
